﻿Type=Activity
Version=5.8
ModulesStructureVersion=1
B4A=true
@EndOfDesignText@
#Region  Activity Attributes 
	#FullScreen: False
	#IncludeTitle: True
#End Region

Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

End Sub

Sub Globals
	'These global variables will be redeclared each time the activity is created.
	'These variables can only be accessed from this module.

	Private psubjects As Panel
	Private pgrade As Panel
	Private selSubject="",selGrade="" As String
	Private pgradeoutter As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
	'Do not forget to load the layout file created with the visual designer. For example:
	Activity.LoadLayout("layselectsubjectgrade")
	initviews
End Sub
Sub initviews
	
	'构建科目选择器
	Dim lstSubjects As List=g_store.conf.Get(comm.S_SUBJECTS)
	Dim ts As Subject
	Dim nW=25%x,nH=6%y As Int
	Dim nJg As Int=(100%x-nW*3)/4
	Dim nT,nL As Int
	nL=nJg
	For i=0 To lstSubjects.Size-1
		ts=lstSubjects.Get(i)
		Dim rb As Button
		rb.Initialize("lblsub")
		rb.Text=ts.name
		rb.Textsize=12
		Dim sldSub As StateListDrawable
		sldSub.Initialize
		Dim cdNor As ColorDrawable
		cdNor.Initialize2(Colors.White,5,1,Colors.Black)
		Dim cdPre As ColorDrawable
		cdPre.Initialize2(Colors.White,5,1,comm.N_COLOR_TITLE)
		sldSub.AddState(sldSub.State_Disabled,cdPre)
		sldSub.AddState(sldSub.State_Pressed,cdPre)
		sldSub.AddCatchAllState(cdNor)
		rb.Background=sldSub
		rb.Gravity=Gravity.CENTER
		rb.TextColor=Colors.Black
		nT=nH*(Floor(i/3))+(nJg/2)*((Floor(i/3)+1))
		nL=nW*(i mod 3)+nJg*((i mod 3)+1)
		psubjects.AddView(rb,nL,nT,nW,nH)
	Next
	psubjects.Height=nT+nH+nJg/2
	pgradeoutter.Top=psubjects.Top+psubjects.Height
	'年级构建
	Dim lstGrades As List=g_store.conf.Get(comm.S_NIANJI_FINDTEACHER)
	Dim nJg As Int=(100%x-nW*3)/4
	Dim nT,nL As Int
	nL=nJg
	Dim str As String
	For i=0 To lstGrades.Size-1
		str=lstGrades.Get(i)
		Dim rb As Button
		Dim sldSub As StateListDrawable
		sldSub.Initialize
		Dim cdNor As ColorDrawable
		cdNor.Initialize2(Colors.White,5,1,Colors.Black)
		Dim cdPre As ColorDrawable
		cdPre.Initialize2(Colors.White,5,1,comm.N_COLOR_TITLE)
		sldSub.AddState(sldSub.State_Disabled,cdPre)
		sldSub.AddState(sldSub.State_Pressed,cdPre)
		sldSub.AddCatchAllState(cdNor)
		rb.Initialize("lblgrade")
		rb.Text=str
		rb.Textsize=12
		rb.Gravity=Gravity.CENTER
		rb.Background=sldSub
		rb.TextColor=Colors.Black
		nT=nH*(Floor(i/3))+(nJg/2)*((Floor(i/3)+1))
		nL=nW*(i mod 3)+nJg*((i mod 3)+1)
		pgrade.AddView(rb,nL,nT,nW,nH)
	Next
	pgrade.Height=nT+nH+nJg/2
	comm.aio(Activity)
End Sub
Sub lblsub_Click
	Dim lbl As Button=Sender
	Log(lbl.text)
	For Each v As Button In psubjects.GetAllViewsRecursive
		If v.Text.EqualsIgnoreCase(lbl.Text) Then
			v.TextColor=comm.N_COLOR_TITLE
			v.Enabled=False
		Else
			v.Enabled=True
			v.TextColor=Colors.Black
		End If
		'v.Invalidate
	Next
	selSubject=lbl.Text
	If selSubject.Length>0 And selGrade.Length>0 Then
		CallSubDelayed3(acthelpyoufindteacher,"gotRec",selSubject,selGrade)
		Activity.Finish
	End If
End Sub
Sub lblgrade_Click
	Dim lbl As Button=Sender
	Log(lbl.text)
	For Each v As Button In pgrade.GetAllViewsRecursive
		If v.Text.EqualsIgnoreCase(lbl.Text) Then
			v.TextColor=comm.N_COLOR_TITLE
			v.Enabled=False
		Else
			v.Enabled=True
			v.TextColor=Colors.Black
		End If
	Next
	selGrade=lbl.Text
	If selSubject.Length>0 And selGrade.Length>0 Then
		CallSubDelayed3(acthelpyoufindteacher,"gotRec",selSubject,selGrade)
		Activity.Finish
	End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnleft_Click
	Activity.Finish
End Sub